package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.LbsTrack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-07-05 11:06:23
 */
@Repository
public class LbsTrackDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(LbsTrackDao.class);

    public LbsTrack insert(final LbsTrack lbsTrack) {
        insert("LbsTrack.insert", lbsTrack);
        return lbsTrack;
    }

    public Boolean updateInfoById(final LbsTrack lbsTrack) {
        return update("LbsTrack.updateInfoById", lbsTrack) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("LbsTrack.updateInfoByQuery", query) > 0;
    }

    public LbsTrack selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("LbsTrack.selectById", query);
    }

    public List<LbsTrack> selectByQuery(final Query query) {
        return queryForList("LbsTrack.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("LbsTrack.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        LbsTrack lbsTrack = new LbsTrack();
        lbsTrack.setDeleteFlag(1);
        lbsTrack.setId(id);
        lbsTrack.setEntId(entId);

        return update("LbsTrack.updateInfoById", lbsTrack) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("LbsTrack.deleteById", query) > 0;
    }
}